package edu.mis.modules.orderDetailCustomer;

import com.jfinal.plugin.activerecord.Record;
import edu.mis.model.OrderDetailCustomer;

import java.util.List;


public class OrderDetailCustomerService {
	public boolean addOrderDetailCustomer(OrderDetailCustomer orderDetailCustomer){
		return orderDetailCustomer.save();

	}
	public boolean updateOrderDetailCustomer(OrderDetailCustomer orderDetailCustomer){
		return orderDetailCustomer.update();
	}
	public boolean deleteOrderDetailCustomerById(int id) {
		return OrderDetailCustomer.dao.deleteById(id);
	}
	/**
	 * 根据ID得到该订单的信息
	 * @param id
	 * @return
	 */
	public OrderDetailCustomer findOrderDetailCustomerById(int id) {
		return OrderDetailCustomer.dao.findById(id);
	}

	public List<Record> findAllOrderDetailCustomersWithCustomer(){
//		return Db.find("SELECT d.id,d.qty,c.commodityName,c.price FROM(SELECT * FROM order_detail  WHERE orderListId=2) d LEFT JOIN commodity c on d.commodityId=c.id");
		return OrderDetailCustomer.dao.findAllOrderDetailCustomersWithCustomer("2");
	}
	public List<Record> findAllRecord(){
		return OrderDetailCustomer.dao.findAllRecord();
	}

	/**
	 * 查询所有订单明细
	 * @return
	 */
	public List<OrderDetailCustomer> findAll(){
		return OrderDetailCustomer.dao.findAll();
	}

}
